<!-- Copyright (c) Microsoft Open Technologies, Inc.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information. -->

<UserControl x:Class="Roslyn.SyntaxVisualizer.Control.SyntaxVisualizerControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="300">
    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Border Grid.Row="0" BorderThickness="1,1,1,0" BorderBrush="#FF828790" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Label Grid.Column="0" VerticalAlignment="Center" Content="Syntax Tree" FontWeight="Bold"/>
                <Button Grid.Column="2" Name="legendButton" Click="LegendButton_Click" Visibility="Hidden" Margin="3" Padding="2" >
                    <StackPanel>
                        <TextBlock>Legend</TextBlock>
                        <Popup StaysOpen="False" Name="legendPopup">
                            <Border BorderThickness="1" BorderBrush="#FF828790">
                                <Grid Background="White">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Row="0" Grid.Column="0" Content="Blue" Foreground="Blue" Margin="5,5,0,0"/>
                                    <Label Grid.Row="0" Grid.Column="1" Content="SyntaxNode" Margin="0,5,5,0"/>
                                    <Label Grid.Row="1" Grid.Column="0" Content="Green" Foreground="DarkGreen" Margin="5,0,0,0"/>
                                    <Label Grid.Row="1" Grid.Column="1" Content="SyntaxToken" Margin="0,0,5,0"/>
                                    <Label Grid.Row="2" Grid.Column="0" Content="Lead:Maroon" Foreground="Maroon" Margin="5,0,0,0"/>
                                    <Label Grid.Row="2" Grid.Column="1" Content="Leading SyntaxTrivia" Margin="0,0,5,0"/>
                                    <Label Grid.Row="3" Grid.Column="0" Content="Trail:Maroon" Foreground="Maroon" Margin="5,0,0,0"/>
                                    <Label Grid.Row="3" Grid.Column="1" Content="Trailing SyntaxTrivia" Margin="0,0,5,0"/>
                                    <Label Grid.Row="4" Grid.Column="0" Content="Pink" Background="Pink" Margin="10,0,0,5" Padding="5,1"  HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <Label Grid.Row="4" Grid.Column="1" Content="Has Diagnostics" Margin="0,0,5,5"/>
                                    <Label Name="highlightLegendTextLabel" Visibility="Collapsed" Grid.Row="5" Grid.Column="0"  Content="Yellow" BorderThickness="1" BorderBrush="Black" Background="Yellow" Margin="10,-5,0,5" Padding="5,1" HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                    <Label Name="highlightLegendDescriptionLabel" Visibility="Collapsed" Grid.Row="5" Grid.Column="1" Content="Of Interest" Margin="0,-5,5,5"/>
                                </Grid>
                            </Border>
                        </Popup>
                    </StackPanel>
                </Button>
            </Grid>
        </Border>
        <TreeView Grid.Row="1" Name="treeView" SelectedItemChanged="TreeView_SelectedItemChanged" PreviewMouseRightButtonDown="TreeView_PreviewMouseRightButtonDown" ContextMenuOpening="TreeView_ContextMenuOpening" Padding="5">
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Style.Resources>
                        <SolidColorBrush 
                            x:Key="{x:Static SystemColors.ControlBrushKey}" 
                            Color="{x:Static SystemColors.HighlightColor}"/>
                    </Style.Resources>
                </Style>
            </TreeView.ItemContainerStyle>
            <TreeView.ContextMenu>
                <ContextMenu Name="treeViewItemContextMenu">
                    <MenuItem Name="directedSyntaxGraphMenuItem" Header="View Directed Syntax Graph" Click="DirectedSyntaxGraphMenuItem_Click">
                        <MenuItem.Icon>
                            <Image Height="16" Width="16" Source="/Roslyn.SyntaxVisualizer.Control;component/SyntaxGraph.ico" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator Name="menuItemSeparator1" />
                    <MenuItem Name="symbolDetailsMenuItem" Header="View Symbol (if any)" Click="SymbolDetailsMenuItem_Click"/>
                    <MenuItem Name="typeSymbolDetailsMenuItem" Header="View TypeSymbol (if any)" Click="TypeSymbolDetailsMenuItem_Click"/>
                    <MenuItem Name="convertedTypeSymbolDetailsMenuItem" Header="View Converted TypeSymbol (if any)" Click="ConvertedTypeSymbolDetailsMenuItem_Click"/>
                    <MenuItem Name="aliasSymbolDetailsMenuItem" Header="View AliasSymbol (if any)" Click="AliasSymbolDetailsMenuItem_Click"/>
                    <Separator Name="menuItemSeparator2" />
                    <MenuItem Name="constantValueDetailsMenuItem" Header="View Constant Value (if any)" Click="ConstantValueDetailsMenuItem_Click"/>
                </ContextMenu>
            </TreeView.ContextMenu>
        </TreeView>
        <GridSplitter Grid.Row="2" ResizeDirection="Rows" HorizontalAlignment="Stretch" Height="5"/>
        <Grid Grid.Row="3">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border Grid.Row="0" BorderThickness="1,1,1,0" BorderBrush="#FF828790" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Label Grid.Row="0" Grid.ColumnSpan="2" Content="Properties" FontWeight="Bold"/>
                    <Label Grid.Row="1" Grid.Column="0" Name="typeTextLabel" Visibility="Hidden" Content="Type" Padding="5,2,5,2" Margin="20,0,0,0"/>
                    <Label Grid.Row="1" Grid.Column="1" Name="typeValueLabel" Padding="5,2,5,2"/>
                    <Label Grid.Row="2" Grid.Column="0" Name="kindTextLabel" Visibility="Hidden" Content="Kind" Padding="5,2,5,2" Margin="20,0,0,0"/>
                    <Label Grid.Row="2" Grid.Column="1" Name="kindValueLabel" Padding="5,2,5,2"/>
                </Grid>
            </Border>
            <WindowsFormsHost Grid.Row="1" Name="windowsFormsHost" Padding="5" />
        </Grid>
    </Grid>
</UserControl>